#  需求：
#    1. 打开register.html
#    2. 填写主页面 页面信息
#    3. 填写注册A 页面信息
#    4. 填写注册B 页面信息
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///root/NSD2408/html/register.html'
driver.get(url)
# 主页面输入值
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#password').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#tel').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#email').send_keys('123@qq.com')

# 切换到A页面
# 提供iframe的 id、name、定位的当前iframe元素
# driver.switch_to.frame('idframe1')
# driver.switch_to.frame('myframe1')
frame = driver.find_element(By.CSS_SELECTOR, '#idframe1')
driver.switch_to.frame(frame)
# 往嵌套的A页面输入内容
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('adminA')
driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telA').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailA').send_keys('123@qq.com')
# 先切换回主页面
# driver.switch_to.parent_frame() # 上级
driver.switch_to.default_content()
# 切换到B页面
driver.switch_to.frame('myframe2')
# 往嵌套的B页面输入内容
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userB').send_keys('adminB')
driver.find_element(By.CSS_SELECTOR, '#passwordB').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telB').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailB').send_keys('123@qq.com')


sleep(3)
driver.quit()